from openai import OpenAI

class AdaptiveRAGPipeline:
    def __init__(self):
        self.model = 'gpt-5'
        self.client = OpenAI(base_url="https://comparegpt.io/api", api_key="cgpt_DsrhFOevoAUk89whFVThkGZfLWHwqy7o")
    def query(self, question: str) -> str:
        """
        简化的 Adaptive RAG 实现，调用大模型返回答案。
        可以在此扩展：检索 -> 生成 -> 自适应调整。
        """
        print(question)
        response = self.client.chat.completions.create(
            model=self.model,
            messages=[
                { "role": "user", "content": question }
            ],
            stream=False,
        )
        print(response)
        if response.choices:
            return response.choices[0].message.content # type: ignore
        else:
            return response.message  # type: ignore